package clock.socoolby.com.clock.widget.textview.charanimator;

import android.graphics.Canvas;
import android.graphics.Paint;

public abstract class AbstractCharAnimator {
    protected boolean charAnimatorRuning;
    protected float charAnimatorPercent;

    protected String preString,currentString;

    public AbstractCharAnimator(String preString, String currentString) {
        this.preString = preString;
        this.currentString = currentString;
        charAnimatorRuning=true;
        charAnimatorPercent=0f;
    }

    public void drawCharAnimator(Canvas canvas, float startX, float startY, Paint mTextPaint){
        drawCharPre(canvas, preString, startX, startY, mTextPaint,charAnimatorPercent);
        drawCharCurrent(canvas, currentString, startX, startY, mTextPaint,charAnimatorPercent);
        move();
    }

    public abstract void drawCharPre(Canvas canvas,String strToDraw, float startX, float startY, Paint mTextPaint,final float percent);

    public abstract void drawCharCurrent(Canvas canvas,String strToDraw, float startX, float startY, Paint mTextPaint,final float percent);

    public  void move(){
        charAnimatorPercent+=0.05f;
        if(charAnimatorPercent>1)
            charAnimatorRuning=false;
    }

    public boolean isCharAnimatorRuning() {
        return charAnimatorRuning;
    }
}
